/*     */ package com.cr.web.controller.system;
/*     */ 
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.domain.Ztree;
/*     */ import com.cr.common.core.domain.entity.SysDictType;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import com.cr.system.service.ISysDictTypeService;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.validation.annotation.Validated;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/system/dict"})
/*     */ public class SysDictTypeController extends BaseController {
/*  34 */   private String prefix = "system/dict/type";
/*     */   
/*     */   @Autowired
/*     */   private ISysDictTypeService dictTypeService;
/*     */   
/*     */   @RequiresPermissions({"system:dict:view"})
/*     */   @GetMapping
/*     */   public String dictType() {
/*  43 */     return this.prefix + "/type";
/*     */   }
/*     */   
/*     */   @PostMapping({"/list"})
/*     */   @RequiresPermissions({"system:dict:list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(SysDictType dictType) {
/*  51 */     startPage();
/*  52 */     List<SysDictType> list = this.dictTypeService.selectDictTypeList(dictType);
/*  53 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @Log(title = "字典类型", businessType = BusinessType.EXPORT)
/*     */   @RequiresPermissions({"system:dict:export"})
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(SysDictType dictType) {
/*  63 */     List<SysDictType> list = this.dictTypeService.selectDictTypeList(dictType);
/*  64 */     ExcelUtil<SysDictType> util = new ExcelUtil(SysDictType.class);
/*  65 */     return util.exportExcel(list, "字典类型");
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  74 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @Log(title = "字典类型", businessType = BusinessType.INSERT)
/*     */   @RequiresPermissions({"system:dict:add"})
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(@Validated SysDictType dict) {
/*  86 */     if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict)))
/*  88 */       return error("新增字典'" + dict.getDictName() + "'失败，字典类型已存在"); 
/*  90 */     dict.setCreateBy(getLoginName());
/*  91 */     return toAjax(this.dictTypeService.insertDictType(dict));
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{dictId}"})
/*     */   public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) {
/* 100 */     mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId));
/* 101 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @Log(title = "字典类型", businessType = BusinessType.UPDATE)
/*     */   @RequiresPermissions({"system:dict:edit"})
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(@Validated SysDictType dict) {
/* 113 */     if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict)))
/* 115 */       return error("修改字典'" + dict.getDictName() + "'失败，字典类型已存在"); 
/* 117 */     dict.setUpdateBy(getLoginName());
/* 118 */     return toAjax(this.dictTypeService.updateDictType(dict));
/*     */   }
/*     */   
/*     */   @Log(title = "字典类型", businessType = BusinessType.DELETE)
/*     */   @RequiresPermissions({"system:dict:remove"})
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/* 127 */     this.dictTypeService.deleteDictTypeByIds(ids);
/* 128 */     return success();
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:dict:remove"})
/*     */   @Log(title = "字典类型", businessType = BusinessType.CLEAN)
/*     */   @GetMapping({"/refreshCache"})
/*     */   @ResponseBody
/*     */   public AjaxResult refreshCache() {
/* 140 */     this.dictTypeService.resetDictCache();
/* 141 */     return success();
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:dict:list"})
/*     */   @GetMapping({"/detail/{dictId}"})
/*     */   public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) {
/* 151 */     mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId));
/* 152 */     mmap.put("dictList", this.dictTypeService.selectDictTypeAll());
/* 153 */     return "system/dict/data/data";
/*     */   }
/*     */   
/*     */   @PostMapping({"/checkDictTypeUnique"})
/*     */   @ResponseBody
/*     */   public String checkDictTypeUnique(SysDictType dictType) {
/* 163 */     return this.dictTypeService.checkDictTypeUnique(dictType);
/*     */   }
/*     */   
/*     */   @GetMapping({"/selectDictTree/{columnId}/{dictType}"})
/*     */   public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType, ModelMap mmap) {
/* 173 */     mmap.put("columnId", columnId);
/* 174 */     mmap.put("dict", this.dictTypeService.selectDictTypeByType(dictType));
/* 175 */     return this.prefix + "/tree";
/*     */   }
/*     */   
/*     */   @GetMapping({"/treeData"})
/*     */   @ResponseBody
/*     */   public List<Ztree> treeData() {
/* 185 */     List<Ztree> ztrees = this.dictTypeService.selectDictTree(new SysDictType());
/* 186 */     return ztrees;
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\web\controller\system\SysDictTypeController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */